import { Schema, model } from 'mongoose';

export interface IPurePage {
  _id?: Schema.Types.ObjectId;
  appId: Schema.Types.ObjectId;
  createdAt?: Date;
  name: string;
  readme?: string;
  size?: string;
  updatedAt?: Date;
}

export const PurePageModel = model<IPurePage>(
  'PurePage',
  new Schema<IPurePage>(
    {
      appId: { ref: 'Application', required: true, type: Schema.Types.ObjectId },
      name: { required: true, type: String },
      readme: { type: String },
      size: { type: String },
    },
    {
      // 自动添加createdAt和updatedAt时间戳
      timestamps: true,
      toObject: {
        getters: true, // 包含虚拟字段
        minimize: false, // 包含空对象
        versionKey: false, // 不包含 __v 版本键
        virtuals: true, // 包含虚拟属性
      },
    },
  ),
);
